<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>表格</title>
    <script src="../js/angular.min.js"></script>
    <style>
        table, th, td {
            border: 1px solid grey;
            border-collapse: collapse;
            padding: 5px;
        }

        /* table tr:nth-child(odd) {
             background-color: #f1f1f1;
         }

         table tr:nth-child(even) {
             background-color: #ffffff;
         }*/
    </style>
</head>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
    <table>
        <tr>
            <th>序号</th>
            <th>姓名</th>
            <th>籍贯</th>
        </tr>
        <tr ng-repeat="x in person |orderBy:'city'">
            <td ng-if="$odd" style="background-color:#f1f1f1">{{$index+1}}</td>
            <td ng-if="$even">{{$index+1}}</td>
            <td ng-if="$odd" style="background-color:#f1f1f1">{{x.name}}</td>
            <td ng-if="$even">{{x.name}}</td>
            <td ng-if="$odd" style="background-color:#f1f1f1">{{x.city}}</td>
            <td ng-if="$even">{{x.city}}</td>
        </tr>
    </table>
</div>
<script>
    var app = angular.module("myApp", []);
    app.controller("myCtrl", function ($scope, $http) {
        $http.get("person.json").success(function (rep) {
            $scope.person = rep.persons;
        });
    });
</script>
</body>
</html>